function [whisking]=find_whisking(imeta_data)

whisking=imeta_data(3:4,:);

for ind=1:2
    whisking(ind,:)=fill_zeros(whisking(ind,:));
end

for ind=1:2
    whisking(ind,:)=whisking(ind,:)-median(whisking(ind,:));
end

whisking=sqrt(whisking(1,:).^2+whisking(2,:).^2);




function out=fill_zeros(in)

fract_zeros=sum(in==0)/length(in);
if fract_zeros>0.1
    disp(['Warning ' num2str(fract_zeros) '% of the whisking data is zeros']);
end

in(1)=1;
go_on=1;
while go_on
    if sum(in==0)>0
        in(in==0)=in(find(in==0)-1);
    else
        go_on=0;
    end
end
out=in;